<!--
/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * Copyright 2014 The moOde audio player project / Tim Curtis
 * Copyright 2020 @bitlab (@bitkeeper Git)
 *
 * 汉化：Androidnews
 *
*/
-->
<div id="container">
<div class="container">
	<h1 class="cdsp-config">CamillaDSP</h1>
	<p class="sub-legend>">Version: $_select[version]</p>
	<p>
		CamillaDSP是一个数字信号处理(DSP)工具,用于路由和过滤声音.它可以用于软件分频、房间校正、均衡和许多其他类型的DSP.有关更多信息,请查看CamillaDSP文档
		 <a class="target-blank-link" href="https://github.com/HEnquist/camilladsp?tab=readme-ov-file#table-of-contents" target="_blank">CamillaDSP documentation</a> 获得更多信息.<br>
	</p>

	<form class="form-horizontal" action="" method="post" >
		<legend>配置
			<button class="legend-config btn btn-medium btn-primary btn-submit" type="submit" name="save" value="1" $_save_disabled>更新</button>
		</legend>
		<p class="sub-legend $_camilladsp_set_disabled_message">
			To use CamillaDSP turn off all other DSP, EQ and Multiroom options in Audio and Multiroom Config.
		</p>

		<div class="config-horiz-rule">常规</div>

		<div class="control-group">
			<label class="control-label" for="cdsp-mode">信号处理</label>
			<div class="controls">
				<select id="cdsp-mode" class="config-select-xxlarge" name="cdsp_mode" $_save_disabled>
					$_select[cdsp_mode]
				</select>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-mode" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="cdsp-config-description" class="config-help-static">
					$_config_description
				</span>
				<span id="info-cdsp-mode" class="config-help-info">
					<b>Off:</b> No signal processing will occur.<br>
					<b>Custom:</b> Manually create a CamillaDSP setup for example when using multiple output devices.<br>
					<b>Quick convolution:</b> Use the selection in "Quick convolution filter" below to provide basic convolution with gain.<br>
					<b>Configurations:</b> Use one of the listed pipeline configurations.
				</span>
			</div>

			<label class="control-label">默认设备选项</label>
			<div class="controls">
				<div class="toggle">
					<label class="toggle-radio toggle-cdsp-use-default-device" for="toggle-cdsp-use-default-device-2">开</label>$_select[cdsp_use_default_device_on]
					<label class="toggle-radio toggle-cdsp-use-default-device" for="toggle-cdsp-use-default-device-1">关</label>$_select[cdsp_use_default_device_off]
				</div>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-use-default-device" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span class="config-help-static">
					ALSA: $_alsa_output_mode
				</span>
				<span id="info-cdsp-use-default-device" class="config-help-info">
					<b>ON:</b> Use the output device and mode defined in Audio Config and a Playback bit depth equal to the highest bit depth reported by the audio device.<br>
					<b>OFF:</b> Specify device options using the Pipeline editor for example if you want to create a multi-channel crossover or set a specific Playback bit depth.
				</span>
			</div>

            <label class="control-label" for="log-level">日志标准</label>
            <div class="controls">
				<select id="log-level" name="log_level" class="config-select-large">
					$_cdsp_log_level
				</select>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-log-level" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="info-log-level" class="config-help-info">
					Control the amount of detail for CamillaDSP entries in the MPD log.
               </span>
            </div>
		</div>

		<div class="config-horiz-rule">快速卷积滤波器</div>

		<div class="control-group">
			<label class="control-label" for="cdsp-qc-gain">Gain (dB)</label>
			<div class="controls">
				<input class="config-input-large" type="number" maxlength="3" min="-40" max="20" step="0.1" id="cdsp-qc-gain" name="cdsp_qc_gain" value="$_cdsp_qc_gain">
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-qc-gain" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="info-cdsp-qc-gain" class="config-help-info">
					Adjusting the Gain can help prevent clipping. The range is -40dB to 20dB. Open the Pipeline editor to see if the signal is clipping or to show the frequency curve of the filter.
				</span>
			</div>

			<label class="control-label" for="cdsp-qc-ir-left">IR left</label>
			<div class="controls">
			    <select id="cdsp-qc-ir-left" class="config-select-xxlarge" name="cdsp_qc_ir_left">
					$_select[cdsp_qc_ir_left]
				</select>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-qc-ir-left" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="info-cdsp-qc-ir-left" class="config-help-info">
					Select an impulse response to use for the convolution. New impulse reponse files can be added in the File management section.
				</span>
			</div>

			<label class="control-label" for="cdsp-qc-ir-right">IR right</label>
			<div class="controls">
			    <select id="cdsp-qc-ir-right" class="config-select-xxlarge" name="cdsp_qc_ir_right">
					$_select[cdsp_qc_ir_right]
				</select>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-qc-right" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="info-cdsp-qc-right" class="config-help-info">
					Select an impulse response to use for the convolution. New impulse reponse files can be added in the File management section.
				</span>
			</div>

			<label class="control-label" for="cdsp-qc-ir-type">类型/格式</label>
			<div class="controls">
			    <select id="cdsp-qc-ir-type" class="config-select-large" name="cdsp_qc_ir_type">
					$_select[cdsp_qc_ir_type]
				</select>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-qc-type" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				$_check_msg_quick_convolution
				<span id="info-cdsp-qc-type" class="config-help-info">
					Specify the type for the selected impulse response file. Note for wav files select WAVE, there is no need to convert the files to raw.
				</span>
			</div>
		</div>
	</form>

	<form class="form-horizontal" action="#pipeline-editor" method="post">
		<a id="pipeline-editor"></a>

		<legend>管道编辑器
			<a href="cdsp-configeditor.php" target="camillagui"><button class="legend-config btn btn-medium btn-primary" $_open_camillagui_disabled>打开</button></a>
		</legend>

		<div class="control-group">
			<span class="config-help-static $_camillagui_notfound_show" >
				<span style='color: red'>&#10007;</span> Pipeline editor not found or not installed.
			</span>
			<span class="config-help-static $_camillagui_status_problems">
				<span style='color: red'>&#10007;</span> Unknown problem with Pipeline editor.
			</span>

			<label class="control-label">状态</label>
			<div class="controls">
				<div class="toggle">
					<label class="toggle-radio toggle-camillagui" for="toggle-camillagui-2">开</label>$_select[camillagui_on]
					<label class="toggle-radio toggle-camillagui" for="toggle-camillagui-1">关</label>$_select[camillagui_off]
				</div>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-camillagui" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="info-camillagui" class="config-help-info">
					Show the current On/Off status of the Pipeline editor Web service.
				</span>
				<button id="btn-update-camilla-gui" class="btn btn-medium btn-primary btn-submit" type="submit" name="update_camillagui" value="1" style="display:none"/>
			</div>

			<label class="control-label">专家模式</label>
			<div class="controls">
				<div class="toggle">
					<label class="toggle-radio toggle-camillaguiexpert" for="toggle-camillaguiexpert-2">开</label>$_select[camillaguiexpert_on]
					<label class="toggle-radio toggle-camillaguiexpert" for="toggle-camillaguiexpert-1">关</label>$_select[camillaguiexpert_off]
				</div>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-camillaguiexpert" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="info-camillaguiexpert" class="config-help-info">
					Show advanced options for example Playback/Capture device settings and Resampling.
				</span>
				<button id="btn-update-camilla-gui-expert" class="btn btn-medium btn-primary btn-submit" type="submit" name="update_camillagui_expert" value="1" style="display:none"/>
			</div>
		</div>
	</form>

	<legend>文件管理</legend>
	<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
		<div class="control-group">
			<label class="control-label" for="cdsp-config">配置</label>
			<div class="controls">
			    <select id="cdsp-config" class="config-select-xxlarge" name="cdsp_config" onchange="$('#btn-automatic-check').click();">
					$_select[cdsp_config]
				</select>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-config" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span class="config-help-static">$_check_msg_config</span>
				<span id="info-cdsp-config" class="config-help-info">
					View the <a class="target-blank-link" href="https://github.com/HEnquist/camilladsp?tab=readme-ov-file#table-of-contents" target="_blank">CamillaDSP documentation</a> for information on Pipeline configuration files.<br>
					<b>V2 Sample configurations</b><br>
					<table class="cdsp-help-table">
						<tr><td>ASH-IR R02 Control Room</td><td>Binaural Room Impulse Response R02 Control Room from the ASH-IR dataset (without HpCF)</td></tr>
						<tr><td>Crossfeed Bs2b</td><td>Bs2b from Wang-Yue which contains 5 setting sets. Refer to link for more information</td></tr>
						<tr><td>Crossfeed Mikhail</td><td>Mikhail Naganov, customize with own IR correction</td></tr>
						<tr><td>Crossfeed MPM</td><td>Mikhail Phonitor Mini (MPM). Mikhail Naganov reverse engineered SPL Phonitor Mini Crossfeed with DSP by Ebert-Hanke</td></tr>
						<tr><td>Crossfeed Natural</td><td>Ebert-Hanke implementation of Natural roughly modeled after some publications by Jan Meier</td></tr>
						<tr><td>Crossfeed Chu Moy</td><td>Ebert-Hanke implementation of Pow Chu Moy Crossfeed based on Linkwitz</td></tr>
						<tr><td>Flat</td><td>No signal processing</td></tr>
						<tr><td>Loudness</td><td>Loudness volume curve with 3dB high boost, 6dB low boost and -3dB gain</td></tr>
						<tr><td>MS-Matrix Narrow</td><td>M-S (Mid-Side) matrix with side signal reduced</td></tr>
						<tr><td>MS-Matrix Wide</td><td>M-S (Mid-Side) matrix with side signal increased</td></tr>
						<tr><td>PEQ 10-Band</td><td>Generic example of a 10 band parametric equalizer</td></tr>
						<tr><td>Polarity Inversion</td><td>Invert +/- polarity on both channels</td></tr>
						<tr><td>ProtoDAC</td><td>ProtoDAC TDA1387 X8 Non-oversampling DAC. Invert +/- signal polarity on both channels and apply Flat dither to 16 bit samples</td></tr>
						<tr><td>Trifield 3-channel</td><td>Michael Gerzon derived Trifield decoder. Requires at least 3 channels available for output</td></tr>
					</table>
				</span>
				<button id="btn-automatic-check" class="btn btn-medium btn-primary btn-submit" type="submit" name="check_auto" value="1" style="display:none" ></button>
			</div>

			<div class="controls">
				<a data-toggle="modal" href="#remove-pipeline"><button class="btn btn-medium btn-primary config-btn">移除</button></a>
				<a data-toggle="modal" href="#copy-pipeline"><button class="btn btn-medium btn-primary config-btn">复制</button></a>
				<a data-toggle="modal" href="#create-new-pipeline"><button class="btn btn-medium btn-primary config-btn">新建</button></a>
				<button class="btn btn-medium btn-primary config-btn" type="submit" name="export" value="1">下载</button>

				<label for="pipeline-config" id="choose-pipeline-cfg" class="btn btn-primary btn-medium config-btn">上传</label>
				<input type="file" id="pipeline-config" accept=".yml" name="pipeline_config" style="display:none" onchange="$('#btn-import-pipeline').click();" >
				<button id="btn-import-pipeline" class="btn btn-medium btn-primary btn-submit" type="submit" name="import" value="1"  style="display:none"/>

				<button class="btn btn-medium btn-primary btn-submit config-btn" type="submit" name="check" value="1">检查</button>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-configuration-actions" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<span id="info-configuration-actions" class="config-help-info">
					<b>Remove:</b> Delete the selected configuation file.<br>
					<b>Copy:</b> Copy the selected configuation file to a new file with a different name.<br>
					<b>New:</b> Create a new configuration with minimim required settings.<br>
					<b>Download:</b> Download the selected configuation file.<br>
					<b>Upload:</b> Upload a configuration file. If the file already exists it will be overwritten.<br>
					<b>Check:</b> Check if the selected configuration is valid.
					<br><br>
					<b>Usage notes:</b><br>
					Changes to the configuration are effective immediately after pausing/stopping playback. If CamillaDSP can't
					play audio, errors will be reported to the MPD log <code>/var/log/mpd/log</code> If this is due to channel
					counts or sampling rates not supported by the audio device, adjust CamillaDSP mixers or	resamplers or change
					the audio format passed to CamillaDSP in the ALSA configuration file <code>/etc/alsa/conf.d/camilladsp.conf</code>
					Errors in this file are typically reported in <code>/var/log/moode.log</code> and <code>/var/log/syslog</code>
				</span>
			</div>
		</div>
	</form>

	<form class="form-horizontal" action="#conv-file" method="post" enctype="multipart/form-data">
		<a id="conv-file"></a>

		<div class="control-group">
			<label class="control-label" for="cdsp-coeffs">卷积</label>
			<div class="controls" >
				<select id="cdsp-coeffs" class="config-select-xxlarge" name="cdsp_coeffs" onchange="$('#coeff_remove_id').val($('#cdsp-coeffs :selected').val() );$('#btn-check-coeff').click();">
					$_select[cdsp_coeffs]
				</select>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-cdsp-coeffs" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<div id="info-cdsp-coeffs" class="config-help-info">
					View the <a class="target-blank-link" href="https://github.com/HEnquist/camilladsp#fir" target="_blank">CamillaDSP documentation</a>for infirmation on impulse response files.<br>
 			    </div>
				<span class="config-help-static">
					<table class="cdsp-help-table">
						$_coeff_info_html
					</table>
				</span>
			</div>

			<!-- ids and names aren't correct: (copy of above now)-->
			<div class="controls">
				<a data-toggle="modal" href="#remove-coeff"><button class="btn btn-medium btn-primary config-btn">移除</button></a>
				<button class="btn btn-medium btn-primary config-btn" type="submit" name="export" value="1">下载</button>
				<label for="coeffs-file" id="choose-coeff-cfg" class="btn btn-medium btn-primary config-btn">上传</label>
				<input type="file" id="coeffs-file" accept=".wav,.txt,.raw,.csv" name="coeffs_file" style="display:none" onchange="$('#btn-import-coeff').click();">
				<button id="btn-import-coeff" class="btn btn-medium btn-primary  config-btn btn-submit" type="submit" name="import" value="1"  style="display:none"</button>
				<button id="btn-check-coeff" class="btn btn-medium btn-primary config-btn btn-submit" type="submit" name="info" value="1" style="display:none">Info</button>
				<a aria-label="Help" class="config-info-toggle" data-cmd="info-convolution-actions" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
				<div id="info-convolution-actions" class="config-help-info">
					<b>Remove:</b> Delete the selected convolution file.<br>
					<b>Download:</b> Download the selected convolution file.<br>
					<b>Upload:</b> Upload a convolution file. If the file already exists it will be overwritten.
 			    </div>
			</div>
		</div>
	</form>

	<form class="form-horizontal $_cdsp_extensions_show" action="#extensions" method="post" >
		<a id="extensions"></a>
		<legend>扩展</legend>
		<div class="control-group">
			$extensions_html
		</div>
	</form>

	<form class="form-horizontal" method="post">
		<div class="control-group">
			<label class="control-label">示例配置</label>
			<div class="controls">
				<a data-toggle="modal" href="#install-sample-configs"><button class="btn btn-medium btn-primary config-btn">更新</button></a>
				<span class="config-help-static">
					更新到最新的一组示例管道配置和参数文件.
					这些文件的前缀是一个版本,例如“V2”,因此可以很容易地进行区分.
					<b>注意:</b> 相同名称的文件将被覆盖,因此请确保在更新之前先备份您的CamillaDSP文件.
				</span>
			</div>
		</div>
	</form>

</div>
</div>

<form class="form-horizontal" method="post">
	<div id="remove-pipeline" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="remove-pipeline-label" aria-hidden="true">
		<input id="config_remove_id" type="hidden" name="cdsp_config" value="$_selected_config"/>
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>移除配置?</h3>
		</div>
		<div class="modal-body txtmid">
			<h4>$_selected_config</h4>
			<span class="config-help-static">
				$_disable_rm_msg
			</span>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="remove" value="1" $_disable_rm>确认</button>
		</div>
	</div>
</form>

<form class="form-horizontal" method="post">
	<div id="remove-coeff" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="remove-coeff-label" aria-hidden="true">
		<input id="coeff_remove_id" type="hidden" name="cdsp_coeffs" value="$_selected_coeff"/>
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>移除卷积?</h3>
		</div>
		<div class="modal-body txtmid">
			<h4>$_selected_coeff</h4>
			<span class="config-help-static">
				$_disable_rm_msg
			</span>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="remove" value="1" $_disable_rm>确认</button>
		</div>
	</div>
</form>

<form class="form-horizontal" method="post">
	<div id="copy-pipeline" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="copy-pipeline-label" aria-hidden="true">
		<input type="hidden" name="cdsp_config" value="$_selected_config"/>
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>复制管道?</h3>
		</div>
		<div class="modal-body">
			<div class="control-group">
				<div class="control-group">
					<label class="control-label" for="selected-pipeline-name">From</label>
					<div class="controls">
						<input id="selected-pipeline-name" class="config-modal-input" type="text" value="$_selected_config" readonly>
					</div>
					<label class="control-label" for="copyto-pipeline-name">To</label>
					<div class="controls">
						<input id="copyto-pipeline-name" class="config-modal-input" type="text" pattern="[A-Za-z0-9 \-_]*" name="copyto_pipeline_name" value="" autofocus>
					</div>
				</div>
			</div>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="copy_pipeline" value="1">确认</button>
		</div>
	</div>
</form>

<form class="form-horizontal" method="post">
	<div id="create-new-pipeline" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="new-pipeline-label" aria-hidden="true">
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>创建新的管道?</h3>
		</div>
		<div class="modal-body">
			<div class="control-group">
				<label class="control-label" for="new-pipeline-name">名称</label>
				<div class="controls">
					<input class="config-modal-input" type="text" pattern="[A-Za-z0-9 \-_]*" id="new-pipeline-name" name="new_pipeline_name" value="" autofocus>
				</div>
			</div>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="create_new_pipeline" value="1">确认</button>
		</div>
	</div>
</form>

<form class="form-horizontal" method="post">
	<div id="install-sample-configs" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="install-sample-configs-label" aria-hidden="true">
		<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h3>更新到最新示例配置?</h3>
		</div>
		<div class="modal-body"></div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button class="btn btn-primary btn-submit" type="submit" name="install_sample_configs" value="1">确认</button>
		</div>
	</div>
</form>
